<template>
    <view class="uni-popup-share">
        <view class="uni-share-title"
            ><text class="uni-share-title-text">{{ title }}</text></view
        >
        <view class="uni-share-content">
            <view class="uni-share-content-box">
                <view
                    class="uni-share-content-item"
                    v-for="(item, index) in bottomData"
                    :key="index"
                    @click.stop="select(item, index)">
                    <image class="uni-share-image" :src="item.icon" mode="aspectFill"></image>
                    <text class="uni-share-text">{{ item.text }}</text>
                </view>
            </view>
        </view>
        <view class="uni-share-button-box">
            <button class="uni-share-button" @click="close">取消</button>
        </view>
    </view>
</template>

<script>
import popup from "@/uni_modules/uni-popup/components/uni-popup/popup.js"
export default {
    name: "UniPopupShare",
    mixins: [popup],
    emits: ["select"],
    props: {
        title: {
            type: String,
            default: "分享到",
        },
        beforeClose: {
            type: Boolean,
            default: false,
        },
    },
    data() {
        return {
            bottomData: [
                // {
                // 	text: '微信',
                // 	icon: '/static/sharemenu/wechatfriend.png',
                // 	name: 'wx'
                // },
                {
                    text: "面对面支付",
                    icon: "/static/sharemenu/facetoface.png",
                    name: "face",
                },
                // {
                // 	text: '复制链接',
                // 	icon: '/static/sharemenu/copylink.png',
                // 	name: 'link'
                // }
            ],
        }
    },
    created() {},
    methods: {
        /**
         * 选择内容
         */
        select(item, index) {
            this.$emit("select", {
                item,
                index,
            })
            this.close()
        },
        /**
         * 关闭窗口
         */
        close() {
            if (this.beforeClose) return
            this.popup.close()
        },
    },
}
</script>
<style lang="scss" scoped>
.uni-popup-share {
    background-color: #eeeeee;
    border-radius: 40rpx 40rpx 0 0;
}
.uni-share-title {
    /* #ifndef APP-NVUE */
    display: flex;
    /* #endif */
    flex-direction: row;
    align-items: center;
    justify-content: center;
    padding: 24rpx 0 20rpx;
}
.uni-share-title-text {
    font-size: 30rpx;
    color: #666;
}
.uni-share-content {
    /* #ifndef APP-NVUE */
    display: flex;
    /* #endif */
    flex-direction: row;
    justify-content: center;
    padding-top: 20rpx;
}

.uni-share-content-box {
    /* #ifndef APP-NVUE */
    display: flex;
    /* #endif */
    justify-content: space-around;
    flex-direction: row;
    flex-wrap: wrap;
    width: 100%;
    padding: 0 24rpx;
}

.uni-share-content-item {
    /* #ifndef APP-NVUE */
    display: flex;
    /* #endif */
    flex: 1;
    flex-direction: column;
    justify-content: center;
    padding: 10px 0;
    align-items: center;
}

.uni-share-content-item:active {
    background-color: #f5f5f5;
}

.uni-share-image {
    width: 112rpx;
    height: 112rpx;
}

.uni-share-text {
    margin-top: 16rpx;
    font-size: 28rpx;
}

.uni-share-button-box {
    /* #ifndef APP-NVUE */
    display: flex;
    /* #endif */
    flex-direction: row;
    padding: 10px 15px;
}

.uni-share-button {
    flex: 1;
    border-radius: 45rpx;
    height: 90rpx;
    font-size: 36rpx;
    background: $color-white;
}

.uni-share-button::after {
    border-radius: 50px;
}
</style>
